;
define(function (required, exports, modules) {
    var modal = require('mods/modal')
    var _csrf = $('#csrf').val()
    exports.add_assign = function () {
        $('.assign').click(function () {

            var admin_id = $(this).attr('data-id')

            $.ajax({
                url: '/admin/permissions/set',
                type: "POST",
                dataType: 'json',
                data: {
                    admin_id: admin_id,
                    _csrf: _csrf
                },
                success: function (res) {
                    if (res.code == 200) {
                        modal.msg(res.msg, {}, function () {
                            window.location.href = '/admin/permissions/set'
                        })
                    } else {
                        modal.alert(res.msg)
                        return false
                    }
                }
            })
        })
    }

    exports.del_role = function () {
        $('.role_del').click(function () {
            var admin_id = $(this).attr('data-id')
            modal.confirm('确定要删除吗?', {}, function () {
                $.ajax({
                    url: '/admin/permissions/ops',
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        admin_id: admin_id,
                        _csrf: _csrf
                    },
                    success: function (res) {
                        if (res.code == 200) {
                            modal.msg(res.msg, {}, function () {
                                window.location.href = '/admin/permissions/set'
                            })
                        } else {
                            modal.alert(res.msg)
                            return false
                        }
                    }
                })
            }, function () {
            });

        })
    }
})